#include <cstdio>
#include <algorithm>
using namespace std;
int main(void){
    int t;
    scanf("%d",&t);
    long long a,b,c,d,e,f;
    while(t--){
        scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
        long long tmp=(c+f)/60;
        long long res3=(c+f)%60;
        tmp=(b+e+tmp)/60;
        long long res2=(b+e+tmp)%60;
        long long res1=(a+d+tmp);
        printf("%lld %lld %lld\n",res1,res2,res3);
    }
    return 0;
}
